home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / Inspector / Sources / Application.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  3.7 KB  |  118 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Application.h
  3.  
  4.     Contains:    TApplication interface
  5.  
  6.     Copyright:    © 1991-1994 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #ifndef __APPLICATION__
  11. #define __APPLICATION__
  12.  
  13. #ifndef __LIBRARYMANAGER__
  14. #include <LibraryManager.h>
  15. #endif
  16.  
  17. #ifndef __DESK__
  18. #include <Desk.h>
  19. #endif
  20.  
  21. #ifndef __OSUTILS__
  22. #include <OSUtils.h>
  23. #endif
  24. #ifndef __QUICKDRAW__
  25. #include <QuickDraw.h>
  26. #endif
  27.  
  28.  
  29. class TDocument;
  30. class TDocumentList;
  31.  
  32. /*
  33.     TApplication:
  34.  
  35.     This is our class which implements a basic Macintosh style program,
  36.     including a MultiFinder-aware event loop. 
  37. */
  38.  
  39. #define kTApplicationID "appl:insp$TApplication,1.2"
  40.  
  41. class TApplication : public TDynamic
  42. {
  43. public:
  44.     // Our constructor & destructor
  45.     TApplication(QDGlobals* qdPtr, BooleanParm initToolbox = true);
  46.     TApplication();
  47.     virtual ~_CDECL TApplication();
  48.  
  49.     // Call this routine to start event loop running
  50.     virtual    void _CDECL EventLoop();
  51.  
  52.     // Utility routines you can use
  53.     inline TDocumentList* DocList() { return fDocList; }
  54.  
  55. protected:
  56.     // Returns total stack space required in bytes.
  57.     // Returns 0 by default, which tells the initialization code
  58.     // to use the default stack size.
  59.     virtual long StackNeeded();
  60.     // Returns total heap space required in bytes.
  61.     // Returns 0 by default, which tells the initialization code
  62.     // to use whatever heap size is given.
  63.     virtual long HeapNeeded();
  64.  
  65.     static    void AlertUser(short errResID, short errCode);
  66.     static    void BigBadError(short errResID, short errCode);
  67.  
  68.     // Loop control methods you may need to override
  69.     virtual void SetUp();                    // Run before event loop starts
  70.     virtual void CleanUp();                    // run at end of loop
  71.     virtual void ExitLoop();                // to end loop, call this routine
  72.     virtual void DoIdle();                    // idle time handler (blink caret, background tasks)
  73.     virtual void AdjustMenus();                // menu updater routine
  74.  
  75.     // event handlers you shouldn't need to override in a typical application
  76.     virtual void DoKeyDown();                // also called for autokey events
  77.     virtual void DoActivateEvt();            // handles setup, and calls DoActivate (below)
  78.     virtual void DoUpdateEvt();                // handles setup, and calls DoUpdate (below)
  79.     virtual void DoOSEvent();                // Calls DoSuspend, DoResume and DoIdle as apropos
  80.     virtual void DoMouseDown();                // Calls DoContent, DoGrow, DoZoom, etc
  81.     virtual void DoMouseInSysWindow();
  82.     virtual void DoDrag();
  83.     virtual void DoGoAway();                // handles setup, calls TDocument::DoClose
  84.  
  85.     // called by EventLoop and its handlers:
  86.     virtual void AdjustCursor();        // cursor adjust routine, should setup mouseRgn
  87.     virtual void DoMenuCommand(short menuID, short menuItem);
  88.     // called by OSEvent (just calls DoActivate by default, so no clip conversion
  89.     // is done). If you want to convert clipboard, override these routines
  90.     virtual void DoSuspend(Boolean doClipConvert);
  91.     virtual void DoResume(Boolean doClipConvert);
  92.     
  93.     // If you have an app that needs to know about these, override them
  94.     virtual void DoMouseUp();
  95.     virtual void DoDiskEvt();
  96.  
  97.     // Utility routines you need to provide to do MultiFinder stuff
  98.     virtual unsigned long SleepVal();        // how long to sleep in WaitNextEvent
  99.  
  100. private:
  101.     virtual void        InitApplication(QDGlobals* qdPtr, Boolean initToolbox);
  102.  
  103. protected:
  104.     // useful variables
  105.     Boolean            fHaveWaitNextEvent;        // true if we have WaitNextEvent trap
  106.     Boolean            fDone;                    // set to true when we are ready to quit
  107.     EventRecord        fTheEvent;                // our event record
  108.     WindowPtr        fWhichWindow;            // currently active window
  109.     Boolean            fInBackground;            // true if our app is suspended
  110.     Boolean            fWantFrontClicks;        // true if we want front clicks
  111.     RgnHandle        fMouseRgn;                // mouse moved region (set it in your DoIdle)
  112.     TDocument*        fCurDoc;                // currently active document (if any)
  113.     TDocumentList*    fDocList;                // the list of documents
  114.     QDGlobals*        fqd;                    // pointer to our qd globals
  115. };
  116.  
  117. #endif
  118.